<!-- 产品列表 -->
<template>
    <div class="page-box h100 display-flex czbj">
        <p class="title-label">产品列表</p>
        <div class="mt10">
            <dxtable :dataJson="dataJson" :portUrl="portUrl" :qx="qx" ref="databale" :formJson="formJson"
                imgkuTitle="产品图片"></dxtable>
        </div>
    </div>
</template>
<script lang='ts' setup>
import dxtable from "./../../components/util/dxtable.vue";
import { dxget, dxpost, qurl, hf } from "./../../util/index";
import sort from "../../components/util/sort.vue";
import { h, ref, reactive } from "vue";
const props = defineProps({
    pup: { type: String },
});
const initeer = () => {
    databale.value.initDataExpose();
};
let headBtn = [];
const databale = ref();
const klkjse = ref()
// 弹窗公用该列表
let dataJson = reactive([
    {
        title: "产品名称",
        key: "name",
        search: true, // 是否在搜索栏展示
    }, {
        title: "产品分类",
        type: "select",
        options: [],
        key: "productClassification",
        search: true, // 是否在搜索栏展示
        render(row) {
            return klkjse.value.filter(a => a.value == row.productClassification)[0].label
        }
    }, {
        title: "零售价",
        key: "retailPrice",
    },
    {
        title: "产品描述",
        key: "productDescription",
    },
    {
        title: "轮播图",
        key: "banner",
        render(row) {
            if (row.banner) {
                row.banner = row.banner.split(",")
                return h("img", { src: row.banner[0], class: 'cpfmddfgdtr' })
            }

        }
    },
    {
        title: "排序",
        width: 100,
        render(row) {
            row.databaseName = "botproductList";
            return h(sort, {
                row,
                onCallBack: () => {
                    initeer();
                },
            });
        },
    },
    {
        title: "创建时间",
        key: "addTime",
        width: "200",
        type: "daterange",
    },
]);
const Userid = localStorage.id
let portUrl = "BOTTEGA/botproductList?roleid="+Userid;
const qx = {
    DeletePermissionID: "boproductListdel", //删除
    EditPermissionIdentifier: "boproductListbj", // 编辑
    NewPermissionIdentifier: "boproductListxz", // 新建
    ViewPermissionID: "boproductListck", // 查看
};
let formJson = reactive([
    {
        title: "产品名称",
        key: "name",
        type: "input",
        required: true, // 是否为必填
    }, {
        title: "产品分类",
        key: "productClassification",
        type: "select",
        options: klkjse.value,
        val: "1",
        required: true, // 是否为必填
    }, {
        title: "零售价",
        key: "retailPrice",
        type: "input",
        required: true, // 是否为必填
    },
    {
        title: "产品描述",
        key: "productDescription",
        type: "textarea",
    },
    {
        title: "轮播图",
        key: "banner",
        type: "imglist",
        val: []
    },
    {
        key: "roleid",
        val: Userid
    },
]);
let pupVal = props.pup;
const getcplx = async () => {
    const { data }: any = await dxget("dxgjAdmin/getzd?name=botproductClassification",{roid:Userid})
    console.log(data);
    klkjse.value = data
    dataJson[1].options = [
        {
            label: "全部",
            value: ""
        },
        ...klkjse.value
    ]
    formJson[1].options = klkjse.value
}
getcplx()
</script>


